package com.hmall.common.config;

import com.hmall.common.utils.RabbitMqHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

@Configuration
@RequiredArgsConstructor
@Slf4j
@DependsOn("rabbitTemplate")
public class MqConfig {
    @Bean
    public RabbitMqHelper rabbitMqHelper(RabbitTemplate rabbitTemplate) {
        return new RabbitMqHelper(rabbitTemplate);
    }

//    @PostConstruct
//    public void init(){
////        RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
//        rabbitTemplate.setReturnsCallback(new RabbitTemplate.ReturnsCallback() {
//            @Override
//            public void returnedMessage(ReturnedMessage returned) {
//                log.error("触发return callback,");
//                log.debug("exchange: {}", returned.getExchange());
//                log.debug("routingKey: {}", returned.getRoutingKey());
//                log.debug("message: {}", returned.getMessage());
//                log.debug("replyCode: {}", returned.getReplyCode());
//                log.debug("replyText: {}", returned.getReplyText());
//            }
//        });
//    }
}
